package 容器方法测试;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetMain
{
	public static void main(String[] args)
	{
		System.out.println("====");
		Set set = new HashSet();
		/*自我介绍*/
		System.out.println("===="+set);
		/*容器的大小*/
		System.out.println("=="+set.size());
		/*添加*/
		System.out.println("=="+set.add("明天你好"));
		System.out.println("=="+set.add("含着泪微笑"));
		System.out.println("=="+set.size());
		System.out.println("=="+set);
		Set set1 = new HashSet();
		set1.add("越奔跑");
		set1.add("越渺小");
		set.addAll(set1);
		System.out.println("=="+set);
		/*查询*/
		/*是不是包含*/
		System.out.println("=="+set.contains(set1));
		/*是不是相等*/
		System.out.println("=="+set.equals(set1));
		/*是不是空的*/
		System.out.println("=="+set.isEmpty());
		/*把set 变成数组*/
		Object [] obj = set.toArray();
		System.out.println("=="+obj);
		/*用迭代器循环数组*/
		for (Iterator ite = set.iterator(); ite.hasNext();)
		{
			Object object =ite.next();
			System.out.println("=="+object);
		}
		/*增强for 循环*/
		for (Object object : set)
		{
			System.out.println("=="+object);
		}
		/*更新*/
		System.out.println("=="+set);
		/*删除*/
		System.out.println("=="+set.remove("越渺小"));
		System.out.println("=="+set);
	}
}
